package config

import (
	"cooke-home/gateway-service/middleware"
	"cooke-home/gateway-service/proxy"
	"log"

	"github.com/gin-gonic/gin"
)

var Router *gin.Engine

func InitRoute() {
	log.Println("开始初始化路由...")
	Router = gin.Default()

	// 添加中间件
	Router.Use(middleware.Logger())

	// 健康检查接口
	Router.GET("/health", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"status": "ok",
		})
	})

	// 代理路由
	// 认证服务路由
	Router.Any("/auth/*any", proxy.GinProxyHandler("auth-service"))

	// 任务服务路由
	Router.Any("/task/*any", proxy.GinProxyHandler("task-service"))

	log.Println("路由初始化完成")
}
